package com.wanmait.spacesys.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.wanmait.spacesys.dao.ForgetPasswordDAO;
import com.wanmait.spacesys.dao.MyCollectionDAO;
import com.wanmait.spacesys.dao.UpdateUserinfoCenterDAO;
import com.wanmait.spacesys.vo.Userinfo;

/**
 * 控制层:忘记密码
 */
@WebServlet("/ForgetPasswordController")
public class ForgetPasswordController extends BaseController {
	


    //通过用户名修改密码
	protected void correctUsername(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String password=request.getParameter("password");
		 String forgetname=request.getParameter("forgetname");
		//System.out.println(forgetname);
	   // Userinfo userinfo = (Userinfo)request.getSession().getAttribute("forgetname");
		
		System.out.println(forgetname);
		Userinfo userinfo=new Userinfo();
		userinfo.setUsername(forgetname);
	        if(userinfo.getUsername()!=null) {
	       
	    	 userinfo.setPassword(password);
	 		ForgetPasswordDAO.getForgetPasswordDAO().updateUserinfo(userinfo);
	 		this.redirect("/web/user/updateForgetPassword.jsp", request, response);
	         }
	   
	}

	@Override
	protected void doDefault(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.correctUsername(request, response);
		
	}

}
